﻿#ifndef			_LIBINI_DOCUMENT_H_
#define			_LIBINI_DOCUMENT_H_

#include <libini/header.h>
#include <libini/section.h>


namespace Xanadu::ini
{
	class LIBINI_EXPORT document
	{
	private:
		// Data list
		std::map<std::string, Xanadu::ini::section>		_memberSectionArray;

	public:
		// constructor
		explicit document(const std::string& _FilePath) noexcept;

		// constructor
		explicit document(const std::wstring& _FilePath) noexcept;

		// constructor
		explicit document(const std::vector<char>& _Bytes) noexcept;

		// constructor
		document(const char* _Bytes, std::size_t _Length) noexcept;

		// destructor
		virtual ~document() noexcept;

	private:
		// Analysis document, returns all section
		static std::list<std::list<std::string>> split_section(const std::list<std::string>& _Strings) noexcept;

	public:
		// Build from file.
		virtual bool from_file(const std::string& _FilePath) noexcept final;

		// Build from file.
		virtual bool from_file(const std::wstring& _FilePath) noexcept final;

		// Build from byte array
		virtual bool from_bytes(const std::vector<char>& _Bytes) noexcept final;

		// Build from string
		virtual bool from_string(const std::string& _String) noexcept final;

		// Build from memory
		virtual bool from_memory(const char* _Bytes, std::size_t _Length) noexcept final;

	public:
		// Serialize to file
		virtual bool to_file(const std::string& _FilePath) noexcept final;

		// Serialize to file
		virtual bool to_file(const std::wstring& _FilePath) noexcept final;

		// Serialize to byte array
		virtual std::vector<char> to_bytes() noexcept final;

		// Serialize to string
		virtual std::string to_string() noexcept final;

	public:
		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, bool _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, char _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, unsigned char _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, short _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, unsigned short _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, int _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, unsigned int _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, long _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, unsigned long _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, long long _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, unsigned long long _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, float _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, double _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, long double _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, const std::vector<char>& _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, const std::vector<unsigned char>& _Value) noexcept;

		// Set value
		virtual bool set_value(const std::string& _Section, const std::string& _Key, const std::string& _Value) noexcept;

	public:
		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, bool& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, char& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, unsigned char&& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, short& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, unsigned short& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, int& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, unsigned int& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, long& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, unsigned long& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, long long& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, unsigned long long& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, float& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, double& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, long double& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, std::vector<char>& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, std::vector<unsigned char>& _Value) noexcept;

		// Get value
		virtual bool value(const std::string& _Section, const std::string& _Key, std::string& _Value) noexcept;
	};
}


#endif
